managed

Implements a managed memory model representation for heap allocated data.

Ensures all memory allocated is accessed in a safe manner but may result in unsafe data usage.
Original concept was for language support link.

This can be thought of in terms of c++ const which is a head only const. A head const is where the pointer may not not change but the data is modifiable. For example an element in array may be changed but it may not be changed to another array.

Compatibility with allocators are a requirement, using IAllocator to represent it. This is a optional element and will by default use theAllocator(). This allows fine grain control over how it allocates on the heap.

When using a COM object as the source, it will assume the responsiblity of AddRef and Releaseing instead of opInc + opDec. Ensuring deallocation when all references are removed. Rule: has secondary ownership and will not attempt to deallocate. But may deallocate at any time.

A managed type is compatible with @safe, "@nogc" and nothrow. However only on the type being represented all of the methods upon managed!T itself is @trusted because of how allocators work.

You may not cast away managed!T or get the real instance of the type. For classes you may cast to a more generic interface/class but not to a more specialised one. For basic types it may be done to another if its size is the same. If the usage will not escape it may be freely used as the real type without casting.

When the managed type is an array, it will wrap all slice actions into returning a managed!T value. This means that all slices are always safe to use and will keep the entirety of the array around until dealloation. Otherwise in normal operations it will act as if it was a normal D array only using allocators for expanding and shrinking.

To retrieve a null version, just use (managed!T).init. It will directly compare to null as true. Since internally it will be comparing to a pointer while using is.

struct managed (
Type
) {}

Destructor

~this
~this()
Undocumented in source.

Postblit

this(this)
this(this)
Undocumented in source.

Alias This

__managedGet

Members

Aliases

AllocatorType
alias AllocatorType = shared(ISharedAllocator)
Undocumented in source.
AllocatorType
alias AllocatorType = IAllocator
Undocumented in source.
__managedAllocator
alias __managedAllocator = processAllocator
Undocumented in source.
__managedAllocator
alias __managedAllocator = theAllocator
Undocumented in source.

Functions

__managedGet
Type __managedGet()
Undocumented in source. Be warned that the author may not have intended to support it.
isNull
bool isNull()

Has this instance been initialized?

opCast
managed!(const(Type)) opCast()

Adds const

opCast
managed!(immutable(Type)) opCast()

Adds immutable

opCast
managed!(CopyConstness!(Type, Type2)) opCast()

Casts class to a more generic type

opCast
managed!(CopyConstness!(Type, Type2)) opCast()

Unsafe-ish dynamic cast, check if is null!

opCast
managed!(CopyConstness!(Type, Type2)) opCast()

Casts a basic type to a similar (aka same sized) type

opCast
managed!(CopyConstness!(Type, Type2)[]) opCast()

Casts an array of classes to a more generic class type

opCast
managed!(CopyConstness!(TypeIf_StructBasic, Type2)[]) opCast()

Casts an array of structs or basic types to a similar (aka same sized) type

Static functions

opCall
managed!Type opCall(Type value, MemoryManagers managers, AllocatorType allocator)

Constructs managed!T where T is a class

opCall
managed!Type opCall(Type value, MemoryManagers managers, AllocatorType allocator)

Constructs managed!T where T is a struct or basic type

opCall
managed!Type opCall(Type value, MemoryManagers managers, AllocatorType allocator)

Constructs managed!T where T is an array with elements of class/struct/basic types

opCall
managed!Type opCall(Type* value, MemoryManagers managers, AllocatorType allocator)

Constructs managed!T where T is a pointer to a class/struct/array/basic type

opCall
managed!Type opCall(MemoryManagers managers, Tuple!ArgsT args, AllocatorType allocator)

Constructs managed!T where T is a struct or class type with arguments

See Also

IMemoryManager, ISharedMemoryManager, managers, ReferenceCountedManager, NeverDeallocateManager

Meta